#include "game.h"
#include "ui_game.h"
#include "gameinterface.h"

game::game(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::game)
{
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);
}

game::~game()
{
    delete ui;
}


void game::on_pushButton_clicked()
{
    this->close();
    GameInterface *gi = new GameInterface;
    gi->Game_start();
    gi->show();
    gi->ID = uID;
 }

void game::on_pushButton_2_clicked()
{
    this->close();
    ranklist *r = new ranklist;
    r->db = this->db;
    r->query = this->query;
    r->show();
}

void game::on_pushButton_3_clicked()
{
    this->hide();
    help *h = new help;
    h->show();
}

void game::on_pushButton_4_clicked()
{
    exit(0);
}

void game::on_pushButton_5_clicked()
{
    int ans;
    setWindowOpacity(0.8);
    settings *s = new settings ;
    ans = s->exec();
    if(ans == 0){
        mcs = new QSound(":/music/backgroundMusic.wav");
        mcs->setLoops(99);
        mcs->play();
    }
    else if(ans == 1){
       mcs->stop();
    }
    setWindowOpacity(1);
}

int game::refh = 0;
void game::on_btn_refresh_clicked()
{
    if(refh == 0){
        ui->game::btn_refresh->setStyleSheet("QPushButton{border-image:url(:/images/refresh2.png)}");
//        //_sleep(100);
//        ui->game::btn_refresh->setStyleSheet("QPushButton{border-image:url(:/images/refresh3.png)}");
//        //_sleep(100);
//         ui->game::btn_refresh->setStyleSheet("QPushButton{border-image:url(:/images/refresh4.png)}");
//         //_sleep(100);
//          ui->game::btn_refresh->setStyleSheet("QPushButton{border-image:url(:/images/refresh.png)}");

          refh = 1;
      }else{
        ui->game::btn_refresh->setStyleSheet("QPushButton{border-image:url(:/images/refresh.png)}");
        refh = 0;
    }

}
